# 作者: 陈其志 
# 2025年02月18日14时58分24秒 
# 2716847110@qq.com

def generate_list_in_a_loop():
    """
    循环生成列表
    :return:
    """
    name_list = []
    i = 0
    for i in range(100):
        name_list.append(i)
    return name_list


def generate_list():
    """
    生成式生成列表
    :return:
    """
    num_list = [x for x in range(100)]
    return num_list


def double_for_cycle():
    """
    双for循环生成列表
    :return:
    """
    a = [j for i in range(5) for j in range(i)]
    print(a)


# 生成二维数组
def two_mid_list():
    """
    生成二维列表
    :return:
    """
    a = [[col * row for col in range(5)] for row in range(5)]  # range(5) = 0.1.2.3.4
    print(a)


# 二维转一维
def two_dim_one():
    a = [[col * row for col in range(5)] for row in range(5)]
    b = [i for j in a for i in j]
    print(b)


if __name__ == '__main__':
    # print("--" * 50)
    # print(generate_list_in_a_loop())
    # print("--" * 50)
    # print(generate_list())
    # print("--" * 50)
    # double_for_cycle()
    # two_mid_list()
    # two_dim_one()
    c = [x for x in range(10) if x % 2 == 1]
    print(c)
    c = [x for x in range(10) if x % 2 == 0]
    print(c)
    # 三元表达式
    a = [x if x % 2 == 0 else x ** 2 for x in range(10)]
    print(a)
